<%--
  Created by IntelliJ IDEA.
  User: sfz
  Date: 2018/5/23
  Time: 15:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="description" content="slick Login">
    <meta name="author" content="Webdesigntuts+">
    <link rel="stylesheet" type="text/css" href="/static/css/admin/login.css"/>
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/plugin/layer/layer.js"></script>
    <script type="text/javascript">
        $(function () {//加载完毕执行

            $("#loginbut").click(function () {//绑定事件
                var username = $("#username").val().trim();
                var password = $("#password").val().trim();
                if (username == null||username==''||username==undefined) {
                    layer.msg("用户名为空");
                    return false;
                }
                if (password == null||password==''||password==undefined) {
                    layer.msg("密码为空");
                    return false;
                }

                $.ajax({
                    url: "${pageContext.request.contextPath}/admin/login",
                    type: "post",
                    dataType: "json",
                    data: {"account": username, "password": password},
                    success: function (result) {
                        if (result.status) {
                            window.location.href = "${pageContext.request.contextPath}/admin/index.html";
                        } else {
                            layer.msg("用户名密码错误")
                        }
                    },
                    error: function () {
                        alert("异常！");
                    }
                });
            });

        });
    </script>
</head>

<body>
<form id="slick-login">
    <label for="username">username</label><input type="text" id="username" name="username" class="placeholder"
                                                 placeholder="悠思博客用户名">
    <label for="password">password</label><input type="password" id="password" name="password" class="placeholder"
                                                 placeholder="悠思博客密码">
    <input type="button" id="loginbut" value="登 陆">
</form>
</body>

</html>
